home *** CD-ROM | disk | FTP | other *** search
/ Minami 85 / MINAMI85.iso / Extra / winamp535.exe / $R0 / Winamp Modern / scripts / configtabs.m < prev    next >
Text File  |  2005-09-15  |  7KB  |  281 lines

  1. #include <lib/std.mi>
  2. #include "attribs.m"
  3.  
  4. function setTabs(int tabstate);
  5. function setTabContent(int contentstate);
  6.  
  7. function OpenDrawer(int animate);
  8. function CloseDrawer(int animate);
  9. function updateAttribs();
  10.  
  11. function ShowDrawer();
  12. function adjustSnapPoints(int DrawerOpen);
  13.  
  14. Global Group frameGroup,PlayerMain,VideoVisGroup;
  15. Global Group tabs,tEQon,tEQoff,tOPTIONSon,tOPTIONSoff,tCOLORTHEMESon,tCOLORTHEMESoff;
  16. Global Group ContentEQ,ContentOPTIONS,ContentCOLORTHEMES;
  17. Global Layer mouseLayerEQ,mouseLayerOPTIONS,mouseLayerCOLORTHEMES;
  18. Global Button btnClose,btnOpen;
  19. Global Group Drawer,DrawerShadow,DrawerContent;
  20. Global GuiObject ColorThemes;
  21. Global Layout main;
  22. Global Int mychange;
  23. Global Boolean loaded=0;
  24. Global Timer deferred_opendrawer;
  25.  
  26. System.onScriptLoaded() {
  27.     initAttribs();
  28.  
  29.     frameGroup = getScriptGroup();
  30.     main = frameGroup.getParentLayout();
  31.  
  32.     tabs=frameGroup.findObject("config.tabs");
  33.     tEQon=frameGroup.findObject("config.tab.eq.on");
  34.     tEQoff=frameGroup.findObject("config.tab.eq.off");
  35.     tOPTIONSon=frameGroup.findObject("config.tab.options.on");
  36.     tOPTIONSoff=frameGroup.findObject("config.tab.options.off");
  37.     tCOLORTHEMESon=frameGroup.findObject("config.tab.colorthemes.on");
  38.     tCOLORTHEMESoff=frameGroup.findObject("config.tab.colorthemes.off");
  39.  
  40.     ColorThemes=frameGroup.findObject("colorthemes");
  41.     PlayerMain=frameGroup.findObject("player.main");
  42.     VideoVisGroup = frameGroup.findObject("AVSGroup");
  43.  
  44.     ContentEQ=frameGroup.findObject("player.normal.drawer.eq");
  45.     ContentOPTIONS=frameGroup.findObject("player.normal.drawer.options");
  46.     ContentCOLORTHEMES=frameGroup.findObject("player.normal.drawer.colorthemes");
  47.  
  48.     mouseLayerEQ=frameGroup.findObject("mousetrapTabEQ");
  49.     mouseLayerOPTIONS=frameGroup.findObject("mousetrapTabOPTIONS");
  50.     mouseLayerCOLORTHEMES=frameGroup.findObject("mousetrapTabCOLORTHEMES");
  51.  
  52.     btnClose = frameGroup.findObject("drawer.button.close");
  53.     btnOpen = frameGroup.findObject("drawer.button.open");
  54.     drawer = frameGroup.findObject("player.normal.drawer");
  55.     DrawerShadow = frameGroup.findObject("player.normal.drawer.shadow");
  56.     DrawerContent = frameGroup.findObject("player.normal.drawer.content");
  57.  
  58.     int tabEQwidth=tEQon.getWidth();
  59.     int tabOPTIONSwidth=tOPTIONSon.getWidth();
  60.  
  61.     int tOPTIONSx=tabEQwidth-3;
  62.     int tCOLORTHEMESx=tabEQwidth+tabOPTIONSwidth-6;
  63.  
  64.     tOPTIONSon.setXmlParam("x",integertostring(tOPTIONSx));
  65.     tOPTIONSoff.setXmlParam("x",integertostring(tOPTIONSx));
  66.     tCOLORTHEMESoff.setXmlParam("x",integertostring(tCOLORTHEMESx));
  67.     tCOLORTHEMESon.setXmlParam("x",integertostring(tCOLORTHEMESx));
  68.  
  69.     mychange = 1;
  70.     setTabs(getPrivateInt("winamp5", "ConfigTab", 1));
  71.     mychange = 0;
  72.     if (getPrivateInt("winamp5", "DrawerOpen", 0)) {
  73.         OpenDrawer(0);
  74.         adjustSnapPoints(1);
  75.     } else {
  76.         adjustSnapPoints(0);
  77.     }
  78.     loaded=1;
  79.     deferred_opendrawer = new Timer;
  80.     deferred_opendrawer.setDelay(250); 
  81. }
  82.  
  83. System.onScriptUnloading() {
  84.     delete deferred_opendrawer;
  85. }
  86.  
  87. setTabs(int tabstate) {
  88.  
  89.     tEQon.hide();
  90.     tOPTIONSon.hide();
  91.     tCOLORTHEMESon.hide();
  92.  
  93.     if (tabstate==1) {
  94.         tEQon.show();
  95.     }
  96.     if (tabstate==2) {
  97.         tOPTIONSon.show();
  98.     }
  99.     if (tabstate==3) {
  100.         tCOLORTHEMESon.show();
  101.     }
  102.  
  103.     setTabContent(tabstate);
  104.     setPrivateInt("winamp5", "ConfigTab", tabstate);
  105.     updateAttribs();
  106. }
  107.  
  108. setTabContent(int contentstate) {
  109.     if (contentstate==1) {
  110.         ContentEQ.show();
  111.         ContentOPTIONS.hide();
  112.         ContentCOLORTHEMES.hide();
  113.     }
  114.     if (contentstate==2) {
  115.         ContentEQ.hide();
  116.         ContentOPTIONS.show();
  117.         ContentCOLORTHEMES.hide();
  118.     }
  119.     if (contentstate==3) {
  120.         ContentEQ.hide();
  121.         ContentOPTIONS.hide();
  122.         ContentCOLORTHEMES.show();
  123.     }
  124. }
  125.  
  126. mouseLayerEQ.onLeftButtonDown(int x, int y) {
  127.     setTabs(1);
  128. }
  129.  
  130. mouseLayerOPTIONS.onLeftButtonDown(int x, int y) {
  131.     setTabs(2);
  132. }
  133.  
  134. mouseLayerCOLORTHEMES.onLeftButtonDown(int x, int y) {
  135.     setTabs(3);
  136. }
  137.  
  138. OpenDrawer(int animate) {
  139.     btnOpen.hide();
  140.     btnClose.show();
  141.     main.beforeRedock();
  142.     if (animate && scrollconfigdrawerattrib.getData() == "1") {
  143.         lockUI();
  144.         drawer.setTargetX(drawer.getGuiX());
  145.         drawer.setTargetY(-147);
  146.         drawer.setTargetW(drawer.getGuiW());
  147.         drawer.setTargetH(drawer.getGuiH());
  148.         drawer.setTargetSpeed(1);
  149.         drawer.gotoTarget();
  150.     } else {
  151.         drawer.setXMLParam("y","-147");
  152.         setPrivateInt("winamp5", "DrawerOpen", 1);
  153.         ColorThemes.show();
  154.         adjustSnapPoints(1);
  155.         updateAttribs();
  156.         main.Redock();
  157.     }
  158.     DrawerShadow.show();
  159. //    main.setXmlParam("minimum_h", "397");
  160. }
  161.  
  162. closeDrawer(int animate) {
  163.     main.beforeRedock();
  164. //    main.setXmlParam("minimum_h", "280");
  165.     ColorThemes.hide();
  166.  
  167.     btnClose.hide();
  168.     btnOpen.show();
  169.     if (animate && scrollconfigdrawerattrib.getData() == "1") {
  170.         lockUI();
  171.         drawer.setTargetX(drawer.getGuiX());
  172.         drawer.setTargetY(-263);
  173.         drawer.setTargetW(drawer.getGuiW());
  174.         drawer.setTargetH(drawer.getGuiH());
  175.         drawer.setTargetSpeed(1);
  176.         drawer.gotoTarget();
  177.     } else {
  178.         drawer.setXMLParam("y","-263");
  179.         DrawerShadow.hide();
  180.         setPrivateInt("winamp5", "DrawerOpen", 0);
  181.         adjustSnapPoints(0);
  182.         updateAttribs();
  183.         main.redock();
  184.     }
  185. }
  186.  
  187. btnClose.onLeftClick() {
  188.     closeDrawer(1);
  189. }
  190.  
  191. btnOpen.onLeftClick() {
  192.     openDrawer(1);
  193. }
  194.  
  195. drawer.onTargetReached() {
  196.     if (btnClose.isVisible()) {
  197.         setPrivateInt("winamp5", "DrawerOpen", 1);
  198.         ColorThemes.show();
  199.         adjustSnapPoints(1);
  200.     } else {
  201.         DrawerShadow.hide();
  202.         setPrivateInt("winamp5", "DrawerOpen", 0);
  203.         adjustSnapPoints(0);
  204.     }
  205.     updateAttribs();
  206.     main.redock();
  207.     unlockUI();
  208. }
  209.  
  210. ShowDrawer() {
  211.     drawer.setXmlParam("y", "-147");
  212.     ColorThemes.show();
  213.     btnOpen.hide();
  214.     btnClose.show();
  215.     DrawerShadow.show();
  216.     adjustSnapPoints(1);
  217. }
  218.  
  219. adjustSnapPoints(int DrawerOpen) {
  220.     int menuHeight=0;
  221.     if (menubar_main_attrib.getData() == "0") menuHeight=17;
  222.     if (DrawerOpen) {
  223.         main.snapAdjust(0,0,0,0+menuHeight);
  224.     } else {
  225.         main.snapAdjust(0,0,0,116+menuHeight);
  226.     }
  227. }
  228.  
  229. menubar_main_attrib.onDataChanged() {
  230.     int menuHeight=0;
  231.     if (getData() == "0") menuHeight=17;
  232.     main.beforeRedock();
  233.     int DrawerOpen=getPrivateInt("winamp5", "DrawerOpen", 0);
  234.     if (DrawerOpen) {
  235.         main.snapAdjust(0,0,0,0+menuHeight);
  236.     } else {
  237.         main.snapAdjust(0,0,0,116+menuHeight);
  238.     }
  239.     main.Redock();
  240. }
  241.  
  242. main.onResize(int x, int y, int w, int h) {
  243.     int newXpos=w/2-163;
  244.     DrawerContent.setXmlParam("x",integertostring(newXpos));
  245. }
  246.  
  247. eq_visible_attrib.onDataChanged() {
  248.   if (mychange) return;
  249.   mychange = 1;
  250.   if (getData() == "1") {
  251.     main.getContainer().switchToLayout("normal"); // instead of main.show(), or linkwidth wont work
  252.     deferred_opendrawer.start();
  253.   } if (getData() == "0") {
  254.     closeDrawer(1);
  255.   }
  256.   mychange = 0;
  257. }
  258.  
  259. deferred_opendrawer.onTimer() {
  260.     stop();
  261.       setTabs(1);
  262.       if (btnOpen.isVisible()) openDrawer(1);
  263. }
  264.  
  265. updateAttribs() {
  266.   if (mychange) return;
  267.   mychange = 1;
  268.   if (tabstate == 1 && !btnOpen.isVisible()) eq_visible_attrib.setData("1"); else eq_visible_attrib.setData("0");
  269.   mychange = 0;
  270. }
  271.  
  272. System.onKeyDown(String key) {
  273.   if (key == "alt+g") {
  274.     if (eq_visible_attrib.getData() == "0")
  275.         eq_visible_attrib.setData("1");
  276.     else
  277.         eq_visible_attrib.setData("0");
  278.     complete;
  279.   }
  280. }
  281.